import mysql.connector
import os
mydb = mysql.connector.connect(
  host="xxxx",       # 数据库主机地址
  user="xxxx",    # 数据库用户名
  passwd="xxxx",
  database="muse"   # 数据库密码
)
mycursor = mydb.cursor()
mycursor.execute("SELECT * FROM img_url_table")
out=open("out.txt","a")
myresult = mycursor.fetchall()     # fetchall() 获取所有记录
for iter in myresult:
    out.write("{}\n".format(iter))